package com.ggh.jinjilive.ui.social.message.chat;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;

import androidx.annotation.Nullable;

import com.blankj.utilcode.util.BarUtils;
import com.ggh.jinjilive.R;
import com.ggh.jinjilive.common.Constants;
import com.ggh.jinjilive.databinding.ActivityChatPageBinding;
import com.ggh.jinjilive.ui.BaseActivity;
import com.gyf.immersionbar.ImmersionBar;
import com.gyf.immersionbar.OnKeyboardListener;
import com.tencent.imsdk.v2.V2TIMConversation;
import com.tencent.imsdk.v2.V2TIMMessage;
import com.tencent.qcloud.tim.uikit.modules.chat.base.ChatInfo;
import com.youth.banner.util.LogUtils;

public class ChatPageActivity extends BaseActivity<ActivityChatPageBinding>  {
    //传递数据
    private V2TIMMessage v2TIMMessage;

    private ChatFragment mChatFragment;


    @Override
    public void initCreate() {
        super.initCreate();
        //解决软键盘与底部输入框冲突问题，默认为false，还有一个重载方法，可以指定软键盘mode
        //单独指定软键盘模式
        ImmersionBar.with(this).keyboardEnable(true).init();
    }

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_chat_page;

    }

    @Override
    public void initParam() {
        super.initParam();
        v2TIMMessage = (V2TIMMessage) getIntent().getSerializableExtra("v2TIMMessage");
    }


    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        chat(intent);
    }

    @SuppressLint("NewApi")
    @Override
    public void initView() {
        super.initView();
        //获取状态栏高度
        binding.llSpacing.setPadding(0, BarUtils.getStatusBarHeight(),0,0);
//        //透明状态栏，白色图标
//        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
//        getWindow().setStatusBarColor(getResources().getColor(R.color.color_2A4FA5));
        chat(getIntent());

    }

    private void chat(Intent intent) {
        Bundle bundle = intent.getExtras();
        ChatInfo mChatInfo = new ChatInfo();
        mChatInfo.setType(V2TIMConversation.V2TIM_C2C);
        mChatInfo.setId(v2TIMMessage.getUserID());
        mChatInfo.setChatName(v2TIMMessage.getNickName());
        bundle.putSerializable(Constants.CHAT_INFO, mChatInfo);
        mChatFragment = new ChatFragment();
        mChatFragment.setArguments(bundle);
        getSupportFragmentManager().beginTransaction().replace(R.id.empty_view, mChatFragment).commitAllowingStateLoss();
        mChatInfo = null;
    }

}
